import axios from "@/utils/request";


//获取菜单列表
export const getMenuListAsync = (params) => {
  const { key } = params
  return axios.get(`/lanlu/menu/list?key=${key}`)
  // return axios.get(`/lanlu/menu/list`)

}


/**
 * 新增
 * id为空获取父级菜单数据
 * 更新
 * id不为空, 获取父级菜单和对应菜单数据
 */
export const getMenuDataAsync = (params) => {
  const { id } = params
  return axios.get(`/lanlu/menu/goSaveOrUpdatePage?id=${id || ''}`)
}


//添加菜单或更新菜单
/**
 * id为空 添加，
 * id不为空 更新
 */
/**
 * {
    "icon": "",
    // "id": 18,
    "orderRank": 20,
    "parentId": 1,
    "title": "我的管理",
    "url": ""
}
 * */
export const addOrUpdateMenuAsync = (params) => {
  return axios.post('/lanlu/menu/saveOrUpdate', params)
}

//删除菜单
/**
 * 200 成功
 * 502 失败
 */
export const deleteMenuDataAsync = (params) => {
  const { id } = params
  return axios.get(`/lanlu/menu/deleteMenu/${id}`)
}


//查询菜单导航列表
export const getNavigationBarMenuListAsync = () => {
  return axios.get('/lanlu/menu/home')
}
